*******************************************************************************************
* Aarøe, Petersen & Arceneaux 2020
* replication dofile for the results from the US 2012 presidential election sample 1
*******************************************************************************************

clear 
set more off

* use the following replication data set
use "Replication dataset for the US 2012 sample 1.dta", replace

*******************************************************************************************

* Recodings

* Contamination disgust from the DS-R
recode q3_4 (0=0) (1=1) (2=2) (3=3) (4=4), gen (toilet04)
recode q3_9 (0=0) (1=1) (2=2) (3=3) (4=4), gen (cook09)
recode q4_4 (0=0) (1=1) (2=2) (3=3) (4=4), gen (soda18)
recode q4_9 (0=0) (1=1) (2=2) (3=3) (4=4), gen (chocl23)
recode q4_12 (0=0) (1=1) (2=2) (3=3) (4=4), gen (condom26)


* scale reliability
alpha toilet04 cook09 soda18 chocl23 condom26

egen contam_av = rmean(toilet04 cook09 soda18 chocl23 condom26)
ta contam_av
gen contam_av01 =contam_av/4

* party identification 
recode q2 (2=0) (3=.) (1=1) (4=.), gen (pid201)
label define pid201 0 "Democrat" 1 "Repblican"
label values pid201 pid201

* household income
recode income_v2 (97=.) (31=.), gen (houseincome)
gen houseincome01=(houseincome-1)/15

* female
gen female = gender-1

* education
gen education01=(educ-1)/5

gen race5=race
recode race5 (1=1) (2=2) (3=3) (4=4) (5=5) (6=5) (7=5) (8=5) (9=5)
ta race5
label define race5 1 "white" 2 "black" 3 "hispanic" 4 "asian" 5 "other"
label values race5 race5

gen white = race5
recode white (1=1) (2=0) (3=0) (4=0) (5=0)
gen black = race5
recode black (1=0) (2=1) (3=0) (4=0) (5=0)
gen hispanic = race5
recode hispanic (1=0) (2=0) (3=1) (4=0) (5=0)
gen asian = race5
recode asian (1=0) (2=0) (3=0) (4=1) (5=0)

* ideology
recode q1 (6=.)
gen ideo01 = (q1-1)/4


*******************************************************************************************
*Descriptive statistics and analyses
*******************************************************************************************

* marginal effects for Figure 1  
* The average marginal effects are also reported on Online Appendix A3.1.1
* the estimates were included in the dataset for the metaanalysis of effects of pathogen avoidance motivation on party preferences
probit pid201 c.contam_av01 c.houseincome01 female age education01 i.race5, level (90)
margins, dydx(contam_av01 houseincome01 education01) level (90) post


* Analysis for Table A7
eststo clear
eststo: probit pid201 c.contam_av01 c.houseincome01 female age education01 i.race5
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.1 ** 0.02 *** 0.002) wide constant r2
eststo clear


* analyses of robustness for Figure 2 reported in Online Appendix A3.2
gen miss=e(sample)
probit pid201 c.houseincome01 female age education01 i.race5 if miss==1, level (90)  
margins, dydx(houseincome01 education01) level (90)


* Supplemental analyses of attitudes on social issues as a pathway linking pathogen avoidance motivation and partisanship
* reported in A3.3, Figure A3
reg ideo01 c.contam_av01 c.houseincome01 female age education01 i.race5
margins, dydx(c.contam_av01)

* sample descriptives for online appendix A1.1.
sum female
sum age 
ta education
ta houseincome
ta income_v2
ta race5

estpost tabstat contam_av01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat pid201, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat ideo01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N") , using part_2.rtf, replace
eststo clear



